package com.ruoyi.coffee.controller;
import com.ruoyi.coffee.dto.QueryProductDto;
import com.ruoyi.coffee.service.ICategoriesService;
import com.ruoyi.coffee.service.IProductsService;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author dxj
 * @Description 咖啡产品
 * @date 2024/12/31 10:31
 */
@RestController
@RequestMapping("/products")
@AllArgsConstructor
@Api(tags = "微信咖啡接口")
public class WxProductsController {
    private final IProductsService productsService;
    private final ICategoriesService categoriesService;
    @GetMapping("/billboards")
    @ApiOperation(value = "5月榜单", notes = "5月榜单")
    public AjaxResult getBillboards() {
        return AjaxResult.success(productsService.billboards());
    }
    @GetMapping("/recommend")
    @ApiOperation(value = "大师推荐", notes = "大师推荐")
    public AjaxResult getRecommend() {
        return AjaxResult.success(productsService.recommend());
    }

    @GetMapping("/category")
    @ApiOperation(value = "咖啡分类", notes = "咖啡分类")
    public AjaxResult getCategory() {
        return AjaxResult.success(categoriesService.getCategoryList());
    }


    @GetMapping("/searchProduct")
    @ApiOperation(value = "分类搜索咖啡", notes = "分类搜索咖啡")
    public AjaxResult searchProduct( QueryProductDto queryProductDto) {
        return productsService.searchProductByCategoryId(queryProductDto);
    }

    @GetMapping("/detail/{productId}")
    @ApiOperation(value = "咖啡详情", notes = "咖啡详情")
    public AjaxResult detail(@PathVariable  Long productId) {
        return AjaxResult.success(productsService.getDetailByProductId(productId));
    }
}

